#ifndef SM4_H
#define SM4_H

#include "common_func.h"
#include <stdint.h>

#define SM4_BASEADDR 		0xbf100000

#define SM4_ENABLE 			SM4_BASEADDR
#define SM4_ENC_DEC_ENABLE 	(SM4_BASEADDR + 0x04)
#define SM4_ENC_DEC_SEL 	(SM4_BASEADDR + 0x08)
#define SM4_VALID		 	(SM4_BASEADDR + 0x0C)
#define SM4_DATA_0		 	(SM4_BASEADDR + 0x10)
#define SM4_DATA_1		 	(SM4_BASEADDR + 0x14)
#define SM4_DATA_2		 	(SM4_BASEADDR + 0x18)
#define SM4_DATA_3		 	(SM4_BASEADDR + 0x1C)
#define SM4_KEY_EXP_IN	 	(SM4_BASEADDR + 0x20)
#define SM4_KEY_VALID	 	(SM4_BASEADDR + 0x24)
#define SM4_KEY_0		 	(SM4_BASEADDR + 0x28)
#define SM4_KEY_1		 	(SM4_BASEADDR + 0x2C)
#define SM4_KEY_2		 	(SM4_BASEADDR + 0x30)
#define SM4_KEY_3		 	(SM4_BASEADDR + 0x34)
#define SM4_READY		 	(SM4_BASEADDR + 0x38)
#define SM4_KEY_EXP_OUT	 	(SM4_BASEADDR + 0x3C)
#define SM4_RESULT_0		(SM4_BASEADDR + 0x40)
#define SM4_RESULT_1		(SM4_BASEADDR + 0x44)
#define SM4_RESULT_2		(SM4_BASEADDR + 0x48)
#define SM4_RESULT_3		(SM4_BASEADDR + 0x4C)
#define SM4_ENABLE_INT		(SM4_BASEADDR + 0x50)

#define SM4_WAIT_TIME		0x01

uint32_t sm4_clear(void);
uint32_t sm4_init(uint32_t mode, uint8_t* key);
uint32_t sm4_enc_dec(uint8_t* data, uint8_t * result);
uint32_t sm4_enc_dec_callback(uint8_t * result);
uint32_t sm4_enc_dec_int(uint8_t* data);
uint32_t sm4_init_inkey(uint32_t mode);

#endif 
